/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/
(function(a){function b(a){return a&&a.Object===Object?a:null}function c(a){return function(){try{return a.apply(this,arguments)}catch(b){return C.e=b,C}}}function d(a){throw a}function e(a,b){if(E&&b.stack&&"object"==typeof a&&null!==a&&a.stack&&-1===a.stack.indexOf(I)){for(var c=[],d=b;d;d=d.source)d.stack&&c.unshift(d.stack);c.unshift(a.stack);var e=c.join("\n"+I+"\n");a.stack=f(e)}}function f(a){for(var b=a.split("\n"),c=[],d=0,e=b.length;e>d;d++){var f=b[d];g(f)||h(f)||!f||c.push(f)}return c.join("\n")}function g(a){var b=j(a);if(!b)return!1;var c=b[0],d=b[1];return c===G&&d>=H&&pa>=d}function h(a){return-1!==a.indexOf("(module.js:")||-1!==a.indexOf("(node.js:")}function i(){if(E)try{throw new Error}catch(a){var b=a.stack.split("\n"),c=b[0].indexOf("@")>0?b[1]:b[2],d=j(c);if(!d)return;return G=d[0],d[1]}}function j(a){var b=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(a);if(b)return[b[1],Number(b[2])];var c=/at ([^ ]+):(\d+):(?:\d+)$/.exec(a);if(c)return[c[1],Number(c[2])];var d=/.*@(.+):(\d+)$/.exec(a);return d?[d[1],Number(d[2])]:void 0}function k(a,b){this.id=a,this.value=b}var l={"function":!0,object:!0},m=l[typeof exports]&&exports&&!exports.nodeType?exports:null,n=l[typeof module]&&module&&!module.nodeType?module:null,o=b(m&&n&&"object"==typeof global&&global),p=b(l[typeof self]&&self),q=b(l[typeof window]&&window),r=n&&n.exports===m?m:null,s=b(l[typeof this]&&this),t=o||q!==(s&&s.window)&&q||p||s||Function("return this")(),u={internals:{},config:{Promise:t.Promise},helpers:{}},v=u.helpers.noop=function(){},w=u.helpers.defaultNow=function(){return Date.now?Date.now:function(){return+new Date}}(),x=u.helpers.defaultError=function(a){throw a},y=(u.helpers.isPromise=function(a){return!!a&&!isFunction(a.subscribe)&&isFunction(a.then)},u.helpers.defaultSubComparer=function(a,b){return a>b?1:b>a?-1:0});isFunction=u.helpers.isFunction=function(){var a=function(a){return"function"==typeof a||!1};return a(/x/)&&(a=function(a){return"function"==typeof a&&"[object Function]"==toString.call(a)}),a}();var z=u.NotImplementedError=function(a){this.message=a||"This operation is not implemented",Error.call(this)};z.prototype=Error.prototype;var A=u.NotSupportedError=function(a){this.message=a||"This operation is not supported",Error.call(this)};A.prototype=Error.prototype;var B=u.helpers.notImplemented=function(){throw new z},C=(u.helpers.notSupported=function(){throw new A},{e:{}}),D=u.internals.tryCatch=function(a){if(!isFunction(a))throw new TypeError("fn must be a function");return c(a)};u.config.longStackSupport=!1;var E=!1,F=D(function(){throw new Error})();E=!!F.e&&!!F.e.stack;var G,H=i(),I="From previous event:",J=({}.hasOwnProperty,Array.prototype.slice,u.internals.inherits=function(a,b){function c(){this.constructor=a}c.prototype=b.prototype,a.prototype=new c}),K=(u.internals.addProperties=function(a){for(var b=[],c=1,d=arguments.length;d>c;c++)b.push(arguments[c]);for(var e=0,f=b.length;f>e;e++){var g=b[e];for(var h in g)a[h]=g[h]}},u.internals.addRef=function(a,b){return new na(function(c){return new T(b.getDisposable(),a.subscribe(c))})},u.CompositeDisposable=function(){var a,b,c=[];if(Array.isArray(arguments[0]))c=arguments[0];else for(b=arguments.length,c=new Array(b),a=0;b>a;a++)c[a]=arguments[a];this.disposables=c,this.isDisposed=!1,this.length=c.length}),L=K.prototype;L.add=function(a){this.isDisposed?a.dispose():(this.disposables.push(a),this.length++)},L.remove=function(a){var b=!1;if(!this.isDisposed){var c=this.disposables.indexOf(a);-1!==c&&(b=!0,this.disposables.splice(c,1),this.length--,a.dispose())}return b},L.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=this.disposables.length,b=new Array(a),c=0;a>c;c++)b[c]=this.disposables[c];for(this.disposables=[],this.length=0,c=0;a>c;c++)b[c].dispose()}};var M=u.Disposable=function(a){this.isDisposed=!1,this.action=a||v};M.prototype.dispose=function(){this.isDisposed||(this.action(),this.isDisposed=!0)};var N=M.create=function(a){return new M(a)},O=M.empty={dispose:v},P=M.isDisposable=function(a){return a&&isFunction(a.dispose)},Q=(M.checkDisposed=function(a){if(a.isDisposed)throw new ObjectDisposedError},M._fixup=function(a){return P(a)?a:O}),R=u.SingleAssignmentDisposable=function(){this.isDisposed=!1,this.current=null};R.prototype.getDisposable=function(){return this.current},R.prototype.setDisposable=function(a){if(this.current)throw new Error("Disposable has already been assigned");var b=this.isDisposed;!b&&(this.current=a),b&&a&&a.dispose()},R.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null,a&&a.dispose()}};var S=u.SerialDisposable=function(){this.isDisposed=!1,this.current=null};S.prototype.getDisposable=function(){return this.current},S.prototype.setDisposable=function(a){var b=this.isDisposed;if(!b){var c=this.current;this.current=a}c&&c.dispose(),b&&a&&a.dispose()},S.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this.current;this.current=null}a&&a.dispose()};var T=u.BinaryDisposable=function(a,b){this._first=a,this._second=b,this.isDisposed=!1};T.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;var a=this._first;this._first=null,a&&a.dispose();var b=this._second;this._second=null,b&&b.dispose()}};var U=u.NAryDisposable=function(a){this._disposables=a,this.isDisposed=!1};U.prototype.dispose=function(){if(!this.isDisposed){this.isDisposed=!0;for(var a=0,b=this._disposables.length;b>a;a++)this._disposables[a].dispose();this._disposables.length=0}};var V=u.internals.ScheduledItem=function(a,b,c,d,e){this.scheduler=a,this.state=b,this.action=c,this.dueTime=d,this.comparer=e||y,this.disposable=new R};V.prototype.invoke=function(){this.disposable.setDisposable(this.invokeCore())},V.prototype.compareTo=function(a){return this.comparer(this.dueTime,a.dueTime)},V.prototype.isCancelled=function(){return this.disposable.isDisposed},V.prototype.invokeCore=function(){return Q(this.action(this.scheduler,this.state))};var W=u.Scheduler=function(){function a(){}a.isScheduler=function(b){return b instanceof a};var b=a.prototype;return b.schedule=function(a,b){throw new z},b.scheduleFuture=function(b,c,d){var e=c;return e instanceof Date&&(e-=this.now()),e=a.normalize(e),0===e?this.schedule(b,d):this._scheduleFuture(b,e,d)},b._scheduleFuture=function(a,b,c){throw new z},a.now=w,a.prototype.now=w,a.normalize=function(a){return 0>a&&(a=0),a},a}(),X=W.normalize;W.isScheduler;!function(a){function b(a,b){function c(b){function d(a,b){return g?f.remove(i):h=!0,e(b,c),O}var g=!1,h=!1,i=a.schedule(b,d);h||(f.add(i),g=!0)}var d=b[0],e=b[1],f=new K;return e(d,c),f}function c(a,b){function c(b,d){function g(a,b){return h?f.remove(j):i=!0,e(b,c),O}var h=!1,i=!1,j=a.scheduleFuture(b,d,g);i||(f.add(j),h=!0)}var d=b[0],e=b[1],f=new K;return e(d,c),f}a.scheduleRecursive=function(a,c){return this.schedule([a,c],b)},a.scheduleRecursiveFuture=function(a,b,d){return this.scheduleFuture([a,d],b,c)}}(W.prototype),function(a){a.schedulePeriodic=function(a,b,c){if("undefined"==typeof t.setInterval)throw new A;b=X(b);var d=a,e=t.setInterval(function(){d=c(d)},b);return N(function(){t.clearInterval(e)})}}(W.prototype);var Y,Z,$=(u.internals.SchedulePeriodicRecursive=function(){function a(a){return function(b,c){c(0,a._period);var e=D(a._action)(a._state);e===C&&(a._cancel.dispose(),d(e.e)),a._state=e}}function b(a,b,c,d){this._scheduler=a,this._state=b,this._period=c,this._action=d}return b.prototype.start=function(){var b=new R;return this._cancel=b,b.setDisposable(this._scheduler.scheduleRecursiveFuture(0,this._period,a(this))),b},b}(),function(a){function b(){a.call(this)}return J(b,a),b.prototype.schedule=function(a,b){return Q(b(this,a))},b}(W)),_=(W.immediate=new $,function(a){function b(){for(;e.length>0;){var a=e.dequeue();!a.isCancelled()&&a.invoke()}}function c(){a.call(this)}var e;return J(c,a),c.prototype.schedule=function(a,c){var f=new V(this,a,c,this.now());if(e)e.enqueue(f);else{e=new fa(4),e.enqueue(f);var g=D(b)();e=null,g===C&&d(g.e)}return f.disposable},c.prototype.scheduleRequired=function(){return!e},c}(W)),aa=W.currentThread=new _,ba=function(){var a,b=v;if(t.setTimeout)a=t.setTimeout,b=t.clearTimeout;else{if(!t.WScript)throw new A;a=function(a,b){t.WScript.Sleep(b),a()}}return{setTimeout:a,clearTimeout:b}}(),ca=ba.setTimeout,da=ba.clearTimeout;!function(){function a(b){if(f)ca(function(){a(b)},0);else{var c=e[b];if(c){f=!0;var g=D(c)();Z(b),f=!1,g===C&&d(g.e)}}}function b(){if(!t.postMessage||t.importScripts)return!1;var a=!1,b=t.onmessage;return t.onmessage=function(){a=!0},t.postMessage("","*"),t.onmessage=b,a}var c=1,e={},f=!1;Z=function(a){delete e[a]};var g=new RegExp("^"+String(toString).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),h="function"==typeof(h=o&&r&&o.setImmediate)&&!g.test(h)&&h;if(isFunction(h))Y=function(b){var d=c++;return e[d]=b,h(function(){a(d)}),d};else if("undefined"!=typeof process&&"[object process]"==={}.toString.call(process))Y=function(b){var d=c++;return e[d]=b,process.nextTick(function(){a(d)}),d};else if(b()){var i="ms.rx.schedule"+Math.random(),j=function(b){"string"==typeof b.data&&b.data.substring(0,i.length)===i&&a(b.data.substring(i.length))};t.addEventListener("message",j,!1),Y=function(a){var b=c++;return e[b]=a,t.postMessage(i+b,"*"),b}}else if(t.MessageChannel){var k=new t.MessageChannel;k.port1.onmessage=function(b){a(b.data)},Y=function(a){var b=c++;return e[b]=a,k.port2.postMessage(b),b}}else Y="document"in t&&"onreadystatechange"in t.document.createElement("script")?function(b){var d=t.document.createElement("script"),f=c++;return e[f]=b,d.onreadystatechange=function(){a(f),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},t.document.documentElement.appendChild(d),f}:function(b){var d=c++;return e[d]=b,ca(function(){a(d)},0),d}}();var ea=function(a){function b(){a.call(this)}function c(a,b,c,d){return function(){a.setDisposable(M._fixup(b(c,d)))}}function d(a){this._id=a,this.isDisposed=!1}function e(a){this._id=a,this.isDisposed=!1}function f(a,b,c){return function(){b(a,c)}}return J(b,a),d.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,Z(this._id))},e.prototype.dispose=function(){this.isDisposed||(this.isDisposed=!0,da(this._id))},b.prototype.schedule=function(a,b){var e=new R,f=Y(c(e,b,this,a));return new T(e,new d(f))},b.prototype._scheduleFuture=function(a,b,d){if(0===b)return this.schedule(a,d);var f=new R,g=ca(c(f,d,this,a),b);return new T(f,new e(g))},b.prototype.scheduleLongRunning=function(a,b){var c=N(v);return Y(f(a,b,c)),c},b}(W);W["default"]=W.async=new ea;k.prototype.compareTo=function(a){var b=this.value.compareTo(a.value);return 0===b&&(b=this.id-a.id),b};var fa=u.internals.PriorityQueue=function(a){this.items=new Array(a),this.length=0},ga=fa.prototype;ga.isHigherPriority=function(a,b){return this.items[a].compareTo(this.items[b])<0},ga.percolate=function(a){if(!(a>=this.length||0>a)){var b=a-1>>1;if(!(0>b||b===a)&&this.isHigherPriority(a,b)){var c=this.items[a];this.items[a]=this.items[b],this.items[b]=c,this.percolate(b)}}},ga.heapify=function(a){if(+a||(a=0),!(a>=this.length||0>a)){var b=2*a+1,c=2*a+2,d=a;if(b<this.length&&this.isHigherPriority(b,d)&&(d=b),c<this.length&&this.isHigherPriority(c,d)&&(d=c),d!==a){var e=this.items[a];this.items[a]=this.items[d],this.items[d]=e,this.heapify(d)}}},ga.peek=function(){return this.items[0].value},ga.removeAt=function(b){this.items[b]=this.items[--this.length],this.items[this.length]=a,this.heapify()},ga.dequeue=function(){var a=this.peek();return this.removeAt(0),a},ga.enqueue=function(a){var b=this.length++;this.items[b]=new k(fa.count++,a),this.percolate(b)},ga.remove=function(a){for(var b=0;b<this.length;b++)if(this.items[b].value===a)return this.removeAt(b),!0;return!1},fa.count=0;var ha,ia=u.Observer=function(){},ja=ia.create=function(a,b,c){return a||(a=v),b||(b=x),c||(c=v),new la(a,b,c)},ka=u.internals.AbstractObserver=function(a){function b(){this.isStopped=!1}return J(b,a),b.prototype.next=B,b.prototype.error=B,b.prototype.completed=B,b.prototype.onNext=function(a){!this.isStopped&&this.next(a)},b.prototype.onError=function(a){this.isStopped||(this.isStopped=!0,this.error(a))},b.prototype.onCompleted=function(){this.isStopped||(this.isStopped=!0,this.completed())},b.prototype.dispose=function(){this.isStopped=!0},b.prototype.fail=function(a){return this.isStopped?!1:(this.isStopped=!0,this.error(a),!0)},b}(ia),la=u.AnonymousObserver=function(a){function b(b,c,d){a.call(this),this._onNext=b,this._onError=c,this._onCompleted=d}return J(b,a),b.prototype.next=function(a){this._onNext(a)},b.prototype.error=function(a){this._onError(a)},b.prototype.completed=function(){this._onCompleted()},b}(ka),ma=u.Observable=function(){function a(a,b){return function(c){var d=c.onError;return c.onError=function(b){e(b,a),d.call(c,b)},b.call(a,c)}}function b(){if(u.config.longStackSupport&&E){var b=this._subscribe,c=D(d)(new Error).e;this.stack=c.stack.substring(c.stack.indexOf("\n")+1),this._subscribe=a(this,b)}}return ha=b.prototype,b.isObservable=function(a){return a&&isFunction(a.subscribe)},ha.subscribe=ha.forEach=function(a,b,c){return this._subscribe("object"==typeof a?a:ja(a,b,c))},ha.subscribeOnNext=function(a,b){return this._subscribe(ja("undefined"!=typeof b?function(c){a.call(b,c)}:a))},ha.subscribeOnError=function(a,b){return this._subscribe(ja(null,"undefined"!=typeof b?function(c){a.call(b,c)}:a))},ha.subscribeOnCompleted=function(a,b){return this._subscribe(ja(null,null,"undefined"!=typeof b?function(){a.call(b)}:a))},b}(),na=u.AnonymousObservable=function(a){function b(a){return a&&isFunction(a.dispose)?a:isFunction(a)?N(a):O}function c(a,c){var e=c[0],f=c[1],g=D(f.__subscribe).call(f,e);g!==C||e.fail(C.e)||d(C.e),e.setDisposable(b(g))}function e(b,c){this.source=c,this.__subscribe=b,a.call(this)}return J(e,a),e.prototype._subscribe=function(a){var b=new oa(a),d=[b,this];return aa.scheduleRequired()?aa.schedule(d,c):c(null,d),b},e}(ma),oa=(u.ObservableBase=function(a){function b(a){return a&&isFunction(a.dispose)?a:isFunction(a)?N(a):O}function c(a,c){var e=c[0],f=c[1],g=D(f.subscribeCore).call(f,e);g!==C||e.fail(C.e)||d(C.e),e.setDisposable(b(g))}function e(){a.call(this)}return J(e,a),e.prototype._subscribe=function(a){var b=new oa(a),d=[b,this];return aa.scheduleRequired()?aa.schedule(d,c):c(null,d),b},e.prototype.subscribeCore=B,e}(ma),function(a){function b(b){a.call(this),this.observer=b,this.m=new R}J(b,a);var c=b.prototype;return c.next=function(a){var b=D(this.observer.onNext).call(this.observer,a);b===C&&(this.dispose(),d(b.e))},c.error=function(a){var b=D(this.observer.onError).call(this.observer,a);this.dispose(),b===C&&d(b.e)},c.completed=function(){var a=D(this.observer.onCompleted).call(this.observer);this.dispose(),a===C&&d(a.e)},c.setDisposable=function(a){this.m.setDisposable(a)},c.getDisposable=function(){return this.m.getDisposable()},c.dispose=function(){a.prototype.dispose.call(this),this.m.dispose()},b}(ka));ma.create=function(a,b){return new na(a,b)},"function"==typeof define&&"object"==typeof define.amd&&define.amd?(t.Rx=u,define(function(){return u})):m&&n?r?(n.exports=u).Rx=u:m.Rx=u:t.Rx=u;var pa=i()}).call(this);
//# sourceMappingURL=rx.core.map